import Vue from 'vue'
import VueRouter from 'vue-router'
//引入路由
import layout from '@/views/layout/Layout.vue'
import login from '@/views/login/index.vue'
//导入首页
import Home from '@/views/home/Home.vue'
import { List } from 'echarts'
import { name } from 'pubsub-js'
import { Dialog } from 'element-ui'

// 这是JavaScript中的动态导入语法，用于异步加载模块。
//在这个例子中，使用了箭头函数的方式定义了一个匿名的异步函数，
//函数体中使用了import()函数来动态导入@/views/product/product.vue模块，并将导入的模块赋值给了常量Product。
const Product = () => import('@/views/product/product.vue')
const ProductList = () => import('@/views/product/ProductList.vue')
const ProductCategory = () => import('@/views/product/ProductCategory.vue')

const productAdd = () => import('@/views/product/productAdd.vue')

const Customer = () => import('@/views/customer/Customer.vue')
const customerList = () => import('@/views/customer/CustomerList.vue')


//study 
const study = () => import('@/views/study/one/One.vue')
const studyOne = () => import('@/views/study/one/StudyOne.vue')


//ph
const ph = () => import('@/views/ph/student/one.vue')
const student = () => import('@/views/ph/student/student.vue')



//ai
const prepare = () => import('@/views/ai/prepare.vue') // 准备页
const ai = () => import('@/views/ai/dialogue.vue')


const business = () => import('@/views/business/businessone/One.vue')
const businessOne = () => import('@/views/business/businessone/BusinessOne.vue')










Vue.use(VueRouter)

//配置路由
const routes = [

  {
    path: '/',
    redirect: '/login'  // 添加这一行，默认重定向到登录页面
  },
  {
    path: '/login',
    name: "login",
    component: login
  },

  {
    path: '/home',
    component: layout,


    children: [
      //首页路由时layout的子路由
      {
        path: '/home',
        name: 'home',
        component: Home
      },
      {
        path: '/product',
        name: 'product',
        component: Product,
        children: [
          {
            path: 'list',   //访问路径： /product/list
            name: 'List',
            component: ProductList
          },
          {
            path: 'category',   //访问路径： /product/category
            name: 'category',
            component: ProductCategory
          },
          {
            path: 'add',
            name: 'add',
            component: productAdd,
            meta: {
              activeMenu: '/product/list'
            }

          }

        ]
      },
      {
        path: '/customer',
        name: 'customer',
        component: Customer,
        children: [
          {
            path: 'list',
            name: 'customerList',
            component: customerList

          }
        ]
      },

      //study vue
      {
        path: '/study',
        name: 'study',
        component: study,
        children: [
          {
            path: 'one',
            name: 'studyOne',
            component: studyOne

          }

        ]
      },

      // 平和
      {
        path: '/ph',
        name: '平和',
        component: ph,
        children: [
          {
            path: 'student',
            name: 'studyOne',
            component: student

          }

        ]
      },
      //Ai
      {
        path: '/ai',
        name: 'AI',
        component: prepare,
        children: [
          {
            path: 'dialogue',
            name: 'AIDialogue',
            component: ai
          }
        ]
      },

      {
        path: '/business',
        name: 'business',
        component: business,
        children: [
          {
            path: 'one',
            name: 'businessOne',
            component: businessOne
          }

        ]
      }
    ]

  }
]

// 创建一个路由对象，里面是一个数组，数组里是包含key，value得路由组件
const router = new VueRouter({
  routes
})

export default router
